<?php
/**
 * @ Fmash Top System
 * @ version: 3.0
 * @ author: i.coffee.smile@mail.com
 * @ date:2011-1-27
 * @ file:page.php $13
 */
 
if(isset($_GET['b']))
{
	$pagestr="<a href=\"top.php?p=1&f=$f&b=$b\">1</a>
	<a href=\"top.php?p=2&f=$f&b=$b\">2</a>
	<a href=\"top.php?p=3&f=$f&b=$b\">3</a>
	<a href=\"top.php?p=4&f=$f&b=$b\">4</a>
	<a href=\"top.php?p=5&f=$f&b=$b\">5</a>";
	$pstr = "<span class=\"current\">$page</span>";
	$ostr = "<a href=\"top.php?p=$page&f=$f&b=$b\">$page</a>";
	$c = $page-1;
	$d = $page+1;
	if($page==1){
		$newprev ='';
	}else{
		$newprev = "<a id=\"page-prev\" href=\"top.php?p=$c&f=$f&b=$b\">«</a>";
	}
	if($page==5){
		$newnext ='';
	}else{
		$newnext = "<a id=\"page-next\" href=\"top.php?p=$d&f=$f&b=$b\">»</a>";
	}
}else{
$pagestr=<<<pagest
<a href="top.php?p=1&f=$f">1</a>
<a href="top.php?p=2&f=$f">2</a>
<a href="top.php?p=3&f=$f">3</a>
<a href="top.php?p=4&f=$f">4</a>
<a href="top.php?p=5&f=$f">5</a>
pagest;
	//$page = isset($_GET['p'])?$_GET['p']:'1';
	$pstr = "<span class=\"current\">$page</span>";
	$ostr = "<a href=\"top.php?p=$page&f=$f\">$page</a>";
	$c = $page-1;
	$d = $page+1;
	if($page==1){
		$newprev ='';
	}else{
		$newprev = "<a id=\"page-prev\" href=\"top.php?p=$c&f=$f\">«</a>";
	}
	if($page==5){
		$newnext ='';
	}else{
		$newnext = "<a id=\"page-next\" href=\"top.php?p=$d&f=$f\">»</a>";
	}
}

$newpage = $newprev.str_replace($ostr,$pstr,$pagestr).$newnext;

